package com.bp.api.system;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import com.common.enums.CommonCode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONObject;
import com.common.enums.SystemStatusEnum;
import com.idp.biz.bpaboutus.entity.BpAboutUs;
import com.idp.biz.bpaboutus.service.BpAboutUsService;

/**
 * 关于我们
 */
@RestController
@RequestMapping(value = "/api/about/", method = RequestMethod.POST)
public class AboutUsController {
	private static Logger logger = LoggerFactory.getLogger(AboutUsController.class);
	
	@Autowired
	private BpAboutUsService aboutService;
	
	/**
	 * 关于我们
	 */
	@CrossOrigin
	@RequestMapping("/init")
	public String init(HttpServletRequest request) {
		JSONObject json = new JSONObject();
		try {
			BpAboutUs about = new BpAboutUs();
			about.setStatus(CommonCode.Y.getValue());
			about.setSymbol(CommonCode.Y.getValue());
			List<BpAboutUs> dataList = aboutService.findBySearch(about);
			
			json.put("data", dataList);
			json.put("code", SystemStatusEnum.SUCCESS.getValue());
			json.put("message", SystemStatusEnum.SUCCESS.getName());
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			json.put("code", SystemStatusEnum.SERVERERROR.getValue());
			json.put("message", SystemStatusEnum.SERVERERROR.getName());
		}
		return json.toString();
	}

}
